<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
        .box {
            position: absolute;
            left: 0;
            top: 0;
        }
    </style>
</head>

<body>
    <div class="box">
        x:100px;y:100px</x:100px>
    </div>
    <script>
        // 鼠标跟随，1.事件 2.获取坐标

        // 获取数据
        var obox = document.querySelector('.box')
        document.onmousemove = function(e) {
            // 浏览器左边和上边的数据
            var x = e.clientX
            var y = e.clientY
            console.log(x, y);
            // 鼠标拿到数据,跟随鼠标移动
            obox.style.left = x + 'px'
            obox.style.top = y + 'px'
                // 将数据渲染到页面
            obox.innerHTML = `x:${x}px; y:${y}px`


        }
    </script>
</body>

</html>